Namespace.Use("UI.Theme.Radiobox", function(ns) {
    //  Imports.
    var CanvasButton = Namespace.Import("UI.Object.CanvasButton");

    function RenderRadiobox(ctx, checked, state, text, font) {
        var box_width = 18;
        var box_padding = 10;
        var inner_padding = 3;
        var size = this.AccessSize();
        var enabled = this.AccessEnabled();

        //  Clear the canvas.
        ctx.clearRect(0, 0, size[0], size[1]);

        //  Configure the drawing context.
        ctx.lineWidth = 1;
        ctx.lineCap = "round";

        //  Draw the background.
        if (state != CanvasButton.STATE_UP && enabled) {
            ctx.fillStyle = "rgba(242,242,242,0.32)";
            ctx.fillRect(0, 0, size[0], size[1]);
        }

        //  Draw the box.
        if (state == CanvasButton.STATE_UP || !enabled) {
            ctx.strokeStyle = "rgba(114,114,114,1)";
        } else {
            ctx.strokeStyle = "rgba(48,48,48,1)";
        }
        if (state == CanvasButton.STATE_DOWN || !enabled) {
            ctx.fillStyle = "rgba(242,242,242,1)";
        } else {
            ctx.fillStyle = "white";
        }
        ctx.beginPath();
        ctx.arc(box_padding + box_width / 2, size[1] / 2, box_width / 2, 0, 2 * Math.PI, false);
        ctx.closePath();
        ctx.stroke();
        ctx.fill();

        //  Draw the checked sign.
        if (checked == true) {
            if (!enabled) {
                ctx.fillStyle = "rgba(175,175,175,1)";
            } else {
                ctx.fillStyle = "black";
            }
            ctx.beginPath();
            ctx.arc(box_padding + box_width / 2, size[1] / 2, box_width / 6, 0, 2 * Math.PI, false);
            ctx.closePath();
            ctx.stroke();
            ctx.fill();
        }

        //  Draw the text.
        var max_text_width = size[0] - 3 * box_padding - box_width;
        if (state == CanvasButton.STATE_UP || !enabled) {
            ctx.fillStyle = "rgba(114,114,114,1)";
        } else {
            ctx.fillStyle = "rgba(48,48,48,1)";
        }
        ctx.textAlign = "left";
        ctx.textBaseline = "middle";
        ctx.font = font;
        if (ctx.measureText(text).width > max_text_width) {
            while(text.length > 0 && ctx.measureText(text + "...").width > max_text_width) {
                text = text.substring(0, text.length - 1);
            }
            text = text + "...";
        }
        ctx.fillText(text, box_padding * 2 + box_width, size[1] / 2);
    }

    //  Export public APIs.
    Namespace.Export(ns, "RenderRadiobox", RenderRadiobox);
});